import { Controller,Get, Render,Post,Body,Response} from '@nestjs/common';
import {PostsService} from './posts.service'

@Controller('posts')
export class PostsController {
    constructor(
        private readonly postsService:PostsService,
      ){
    
      }
    @Get()
    @Render('posts')
    index(){
      return {title:'请登录！'}
    }
    @Post('login')
    async login(@Body() body:any,@Response() res){
    //   console.log(body);
    let flag=await this.postsService.login(body)
    if(flag){
        res.redirect('/user')
    }else {
        res.send('用户名密码错误')
    }
    }
}
